package com.qinhailin.portal.dbm.service;

/** 2019-11-05 12:35:27 批量生成 harrydeep@wardyan.top **/
public class CPGetIDService {
	
	private static CPGetIDService instance = null;
	
	public static CPGetIDService getInstance() {
		if(instance == null) {
			instance = new CPGetIDService();
		}
		return instance;
	}

	/** 2019-11-18 **/
	public Integer cp_getid( Integer pID, String pTableName, Integer pQty){

		return (Integer) com.jfinal.plugin.activerecord.Db.execute(new com.jfinal.plugin.activerecord.ICallback(){
			@Override
			public Integer call(java.sql.Connection conn) throws java.sql.SQLException {
				java.sql.CallableStatement proc = conn.prepareCall("{call cp_getid(?,?,?,?)}");
				proc.setInt(1,pID);
				proc.setString(2,pTableName);
				proc.setInt(3,pQty);
				proc.registerOutParameter(4,java.sql.Types.INTEGER);

				proc.execute();

				return proc.getInt(4);
			}
		});
	}
}

